![]() |
Introducing Functions That Return Data
OPENING QUESTION: We explored simple functions such as msg(). Then we worked with functions that receive an argument such as calcArea(rad), where a value for the radius is 'passed into' the function and used there. Then we expanded that to include to different arguments passed in: calcVals(rad, type) where rad is the radius and type is a variable that contains the user's choice of whether to calculate the circumference of a circle (type =c) or the area of the circle (type = a). How many arguments can a function take? If a function takes multiple arguments, the name of the argument is critical. Why is that statement false? OBJECTIVES: I will work with my team to analyze and then write a function that accepts arguments and returns a value during today's class. CALENDAR: WORDS O' THE DAY:
WORK O' THE DAY: The last feature of functions we need to learn is the 'return' command. Functions are often used to process specific data. It is often very helpful to have the results of the work of that function RETURNED back to the main program. The syntax for that is kind of odd:
|